/**
 * 
 */
package com.laozhao.EasySales.control;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JOptionPane;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import com.laozhao.EasySales.model.UserModel;
import com.laozhao.EasySales.view.MainWindowsFrame;
import com.laozhao.EasySales.view.WelcomePanel;
import com.laozhao.EasySales.view.master.SysSqlPanel;
import com.laozhao.dreamframe.util.FrameFactory;

/**
 * @author LaoZhao
 * 
 */
public class MainWindowsAction implements ActionListener {

	private transient Log log = LogFactory.getLog(this.getClass());

	/**
	 * 
	 */
	public MainWindowsAction() {
		super();
	}
	
	/**
	 * 
	 */
	public MainWindowsAction(UserModel user) {
		super();
	}

	public void actionPerformed(ActionEvent e) {
		MainWindowsFrame mainFrame = (MainWindowsFrame) FrameFactory.getInstance(MainWindowsFrame.class);
		String command = e.getActionCommand();
		log.info("Main action start :" + command);
		try {
			if (command.equals("toolgo")) {
				mainFrame.nextPanel();
			} else if (command.equals("toolback")) {
				mainFrame.previous();
			} else if (command.equals("menuSalesReport")) {

			} else if (command.equals("menuPurchaseReport")) {
				
			} else if (command.equals("menuAccountReport")) {
				
			} else if (command.equals("menuDeptReport")) {
				
			} else if (command.equals("menuDetailReport")) {
				
			} else if (command.equals("menuCustomer")) {
				
			} else if (command.equals("menuShop")) {
				
			} else if (command.equals("menuSalesman")) {
				
			} else if (command.equals("menuGoods")) {
				
			} else if (command.equals("menuCalculator")) {

			} else if (command.equals("menuSql")) {
				SysSqlPanel sysSqlPanel = (SysSqlPanel) FrameFactory.getInstance(SysSqlPanel.class);
				sysSqlPanel.init();
				mainFrame.addPane( sysSqlPanel);
			}else if(command.equals("menuAbout")){
				WelcomePanel welcome = (WelcomePanel) FrameFactory.getInstance(WelcomePanel.class);
				welcome.init();
				mainFrame.addPane(welcome);
//				JOptionPane.showMessageDialog(mainFrame, "Welcome use ESMS!");
			}
			log.info("action success :" + command);
		} catch (Exception exp) {
			log.error("Failled action  :" + command);
			log.debug("Failed message:", exp);
			exp.printStackTrace();
		}
//		System.gc();
	}
}
